home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_CHOICE.TXT < prev    next >
Encoding:
Text File  |  1992-12-22  |  6.9 KB  |  166 lines

  1. '
  2. 'Class description:
  3. '
  4. !short:Choice class structure:
  5. Class Choice:
  6. ~~~~~~~~~~~~~~
  7. This class combines properties of simple window Win and clipper function
  8. AChoice.
  9.  
  10.  
  11. Common use:
  12. ~~~~~~~~~~~
  13. LOCAL OBJECT Cho OF Choice
  14. Cho:Init(...)                //or Cho:FastInit(...)
  15. n:=Cho:Process()
  16. Cho:Done()
  17.  
  18. Due to inheritance the methods Hide() and Show() inherited from class Win
  19. can be used for an object of class Choice. The menu can be temporary saved
  20. and then redisplayed and after that by method Choice:Process() call can be
  21. started the menu choice.
  22.  
  23. Source code of class Choice is in C_Choice.prg
  24.  
  25. !seealso: c_win.ngo:Win c_box.ngo:Box c_mnu.ngo:Mnu c_menu.ngo:Menu ob_funct.ngo:AValid ob_funct.ngo:DbfValid c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  26.  
  27. !short:~~~~~~~~~~~~~~~~~~~~~~~~
  28. !short:create class Choice from Win
  29. !short:  export:
  30. !short:  var Items      //{"item1",...}
  31. ^BChoice:Items^N: public: array
  32.   Array of data for AChoice(...) function, which should contain a selectable
  33.   items in form of text strings. Example:
  34.   {"choice1","choice2", ... ,"choiceN"}
  35.  
  36. !short:  var SelItems   //{lSelectable,...}
  37. ^BChoice:SelItems^N: public: array
  38.   Paralell array for Choice:Items used for selectable items marking.
  39.  
  40. !short:  var Cursor     //(object of Cursor)
  41. ^BChoice:Cursor^N: private: object
  42.   Class Cursor object for saving the cursor shape during the menu choice.
  43.  
  44. !short:  var Choice     //1
  45. ^BChoice:Choice^N: read-only: numeric
  46.   Stores the item number of Choice:Items field, selected by user.
  47.   If user instead of selecting by pressing Enter pressed ESC,
  48.   the ^UNegative^N value of actual item number is returned!
  49.  
  50. !short:  var Top        //1
  51. ^BChoice:Top^N: private: numeric
  52.   Stores the number of the first displayed item in a window. (the items could
  53.   scroll). It is used for correct display in repeated activation 
  54.   of Choice:Process method.
  55.  
  56. !short:  var CanAppend  //false
  57. ^BChoice:CanAppend^N: public: logical
  58.   If true, user can by pressing Ins/Del keys activate the code block
  59.   for adding/deletting of an item from Choice:Items. The menu can be
  60.   dynamicaly modified.
  61.  
  62. !short:  var InsBlock   //{|o|nil}
  63. ^BChoice:InsBlock^N: public: code_block
  64.   This code block is activated from Choice:Process() when the Choice:Append
  65.   is true and the user pressed Ins key during the selection. As parameter
  66.   of this code block is passed the self object. The job of this code block
  67.   is to add a new item to Choice:Items, or to reconfigure the instvar
  68.   variables of this object. It enables during the selection
  69.   the adition/deletion of menu items and dynamicaly modify the menu.
  70.  
  71. !short:  var DelBlock   //{|o|nil}
  72. ^BChoice:DelBlock^N: public: code_block
  73.   This code block is activated from Choice:Process() when the Choice:Append
  74.   is true and the user pressed Del key during the selection. As parameter
  75.   of this code block is passed the self object. The job of this code block
  76.   is to delete an item from Choice:Items, or to reconfigure the instvar
  77.   variables of this object. It enables during the selection
  78.   the adition/deletion of menu items and dynamicaly modify the menu.
  79.  
  80. !short:  var InRow      //0
  81. ^BChoice:InRow^N: private: numeric
  82.   Stores the init (row) position  of Choice window on the screen
  83.   for correct repainting after issuing code blocks Choice:InsBlock
  84.   or Choice:DelBlock.
  85.  
  86. !short:  var InCol      //0
  87. ^BChoice:InCol^N: private: numeric
  88.   Stores the init (column) position  of Choice window on the screen
  89.   for correct repainting after issuing code blocks Choice:InsBlock
  90.   or Choice:DelBlock.
  91.  
  92. !short:  var InCurSize  //0
  93. ^BChoice:InCurSize^N: private: numeric
  94.   Stores the value of CursorSize parameter for parrent method Box:GoodInit()
  95.   for correct repainting after issuing code blocks Choice:InsBlock
  96.   or Choice:DelBlock.
  97.  
  98. !short:  method New=ChoiceNew           //o:New() --> self
  99. ^BChoice:New()^N: public: return self
  100.   Object is filled with default values.
  101.  
  102. !short:  method Init=ChoiceInit         //o:Init(Name,R,C,CurSize,Items,SelItems,Clr,Shd) --> true
  103. ^BChoice:Init(Name,R,C,CurSize,Items,SelItems,Clr,Shadow)^N: public: return true
  104.   This method is used for initialising and reasonable window placement
  105.   for clipper function Achoice on the screen, to be as near as possible
  106.   to cursor but not to cover any desired text. (It starts on R,C position
  107.   with length of CurSize). Off course the window must be placed to be whole
  108.   visible. After all preparing job is done the menu is painted to the screen
  109.   and the control goes to calling function.
  110.  
  111.   Parameter description:
  112.   ~~~~~~~~~~~~~~~~~~~~~~
  113.   ^UName^N: text or code block : no default
  114.    Text or code block as window title.
  115.  
  116.   ^UR^N: numeric: default is Row().
  117.    Text position -row- (of cursor) on the screen, which shouldn't be covered
  118.    but the window should be as near as possible to this text.
  119.  
  120.   ^UC^N: numeric: default is Col().
  121.    Text position -column- (of cursor) on the screen, which shouldn't be
  122.    covered but the window should be as near as possible to this text.
  123.  
  124.   ^UCurSize^N: numeric: default is 1.
  125.    Text width, which shouldn't be covered but the window should be as
  126.    near as possible to this text.
  127.  
  128.   ^UItems^N: array: no default must be entered
  129.    It is an array of text strings, repersenting the menu. It is passed
  130.    without any change as parameter to clipper function AChoice().
  131.  
  132.   ^USelItems^N: array: default is an array filled with true-values.
  133.    It is an array (of the same size as the "Items" parameter) controling
  134.    if the items can be selected from menu or the selection of this items
  135.    is not allowed. It is passed without any change as parameter to function
  136.    AChoice().
  137.  
  138.   ^UClr^N: character: default is m->Color:Edit.
  139.    Window colors.
  140.  
  141.   ^UShadow^N: logical: default is true for color monitor, false for monochrom.
  142.    If true the window shadow will be painted.
  143.  
  144. !short:  method FastInit=ChoiceFastInit //o:FastInit(Name,R,C,CurSize,Items,SelItems,Clr,Shd) --> true
  145. ^BChoice:FastInit(Name,R,C,CurSize,Items,SelItems,Clr,Shadow)^N: public:
  146.   return: true
  147.   It is the same as Choice:Init(...) but with diference of initialising jobs
  148.   and the menu is not painted to the screen. The painting is done after
  149.   activating of the method Choice:Process().
  150.  
  151. !short:  method Process=ChoiceProcess   //o:Process() --> nChoice
  152. ^BChoice:Process()^N: public: return nChoice
  153.   This method is making the own choice from the menu, it returns the selected
  154.   item number, if it is negative, the user instead of selecting and pressing
  155.   the Enter key pressed ESC key (he doesn't want to select anything).
  156.   This method can be called repeatedly unrestricted number of times.
  157.   The selected item value is stored to instvar variable Choice:Choice.
  158.  
  159. !short:  method Done=ChoiceDone         //o:Done() --> true
  160. ^BChoice:Done()^N: public: return true
  161.   Stores the menu, i.e. restores the screen and the control goes to calling
  162.   function.
  163.  
  164. !short:  endclass
  165.  
  166.